﻿<html>

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
        <script src="/static/js/common.js"></script>

</head>

<body>
    <div id="app" class="popupW100" v-cloak>
        <!-- class="popupW100"为label宽度为100px，共有popupW50、popupW100、popupW150、popupW200可选 -->
        <el-form label-position="right" :model="Form" status-icon :rules="rules" ref="ruleForm" label-width="100px"
            size="mini">
            <!-- 此处为录入项 循环所有字段，一行四个，不够 补空列 -->
            <el-row>
                <el-col :span="11">
                    <div class="elst-select-mini">
                        <el-form-item>
                            <el-input type="text" v-model="Form.Name" autocomplete="off" size="mini">
                                <template slot="prepend">
                                    {{Questions.Name+mark.m}}

                                </template>
                            </el-input>
                        </el-form-item>
                    </div>
                </el-col>
				</el-row>
				<el-row>
                <el-col :span="11">
                    <div class="elst-select-mini">
                        <el-form-item>
                            <el-input type="text" v-model="Form.Type" autocomplete="off" size="mini">
                                <template slot="prepend">
                                    {{Questions.Type+mark.m}}

                                </template>
                            </el-input>
                        </el-form-item>
                    </div>
                </el-col>
				</el-row>
				<el-row>
                <el-col :span="11">
                    <div class="elst-select-mini">
                        <el-form-item>
                            <el-input type="text" v-model="Form.Level" autocomplete="off" size="mini">
                                <template slot="prepend">
                                    {{Questions.Level+mark.m}}

                                </template>
                            </el-input>
                        </el-form-item>
                    </div>
                </el-col>
				</el-row>
				<el-row>
                <el-col :span="11">
                    <div class="elst-select-mini">
                        <el-form-item>
                            <el-input type="text" v-model="Form.CreatTime" autocomplete="off" size="mini">
                                <template slot="prepend">
                                    {{Questions.CreatTime+mark.m}}

                                </template>
                            </el-input>
                        </el-form-item>
                    </div>
                </el-col>
				</el-row>
				<el-row>
                <el-col :span="11">
                    <div class="elst-select-mini">
                        <el-form-item>
                            <el-input type="text" v-model="Form.Answer" autocomplete="off" size="mini">
                                <template slot="prepend">
                                    {{Questions.Answer+mark.m}}

                                </template>
                            </el-input>
                        </el-form-item>
                    </div>
                </el-col>
            </el-row>

            <el-row type="flex" justify="end">
                <el-form-item>
                    <el-button type="primary" @click="onSubmitForm('ruleForm')">{{col.btnConfirm}}</el-button>
                </el-form-item>
            </el-row>
        </el-form>

    </div>
    <script type="text/javascript">

        var app = new Vue({
            el: '#app',
            data: {
                id: '',
                //业务表单内容 遍历所有字段 id默认为 guidEmpty
                Form: {
                    id: guidEmpty,
                    Name: '',
                    Category: '',
                    Teacher: '',
                    LlearningTime: '',
                    Courseware: '',
                    IsEncrypted: '',

                },
                //表单验证 遍历所有字段 根据数据库字段描述 进行初始化设置  预留3种情况 字数限制、非空、不限制
                rules: {
                    Name: [{ pattern: verification.StringLengthAtoB.t.format(0, 100), message: verification.StringLengthAtoB.m.format(0, 100), trigger: 'blur' }],
                    Category: [{ pattern: verification.StringLengthAtoB.t.format(0, 100), message: verification.StringLengthAtoB.m.format(0, 100), trigger: 'blur' }],
                    Teacher: [{ pattern: verification.StringLengthAtoB.t.format(0, 100), message: verification.StringLengthAtoB.m.format(0, 100), trigger: 'blur' }],
                    LlearningTime: [{ pattern: verification.StringLengthAtoB.t.format(0, 100), message: verification.StringLengthAtoB.m.format(0, 100), trigger: 'blur' }],
                    Courseware: [{ pattern: verification.StringLengthAtoB.t.format(0, 100), message: verification.StringLengthAtoB.m.format(0, 100), trigger: 'blur' }],
                    IsEncrypted: [{ pattern: verification.StringLengthAtoB.t.format(0, 100), message: verification.StringLengthAtoB.m.format(0, 100), trigger: 'blur' }],


                }
            },
            methods: {
                //解決edge下select bug
                visibleChange: function (isVisible) {
                    visibleChange(isVisible)
                },

                onSubmitForm: function (formName) {
                    var mythis = this;
                    this.$refs[formName].validate(function (valid) {
                        if (valid) {
                            //Model 替换成 表名
                            onSubmitForm(this, '/api/Questions/Save', mythis.Form);
                        } else {
                            return false;
                        }
                    });

                },

                getData: function () {

                    //Model 替换成 表名
                    getData(this, '/api/Questions/get?id=' + this.id);

                }
            },
            mounted: function () {
                this.id = getUrlParam("id");
                this.getData();

            }
        });
    </script>
</body>

</html>